/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package toolutils;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

/**
 *
 * @author Administrator
 */
public class ToolUtils {
    // 获取网页内容，错误的情况返回NULL；
    public static String getContent(String strUrl) {
        try {
            URL url = new URL(strUrl);
            BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(),"GB2312"));
            String s = "";
            StringBuffer sb = new StringBuffer("");
            while ((s = br.readLine()) != null) {
                sb.append(s);
            }
            br.close();
            return sb.toString();
        } catch (Exception e) {
            return null;
        }
    }
}
